package fr.umlv.m2.jee.pmlv.persistence.cursus;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.Set;
import javax.persistence.FetchType;

/**
 * Represents a specialty of a cursus. It's a entity.
 * @author jenseric
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name="Specialty")
public class Specialty implements Serializable {

	/**
	 * The id of the Specialty.
	 */
	@Id
	@GeneratedValue
	@Column(name="specialty_id")
	private long id;
	
	/**
	 * The name of the specialty.
	 */
	@Column(name="specialty_name")
	private String name;
	
	/**
	 * The description of the specialty.
	 */
	@Column(name="specialty_description")
	private String description;
	
	/**
	 * The Cursus where we find the specialty.
	 */
	@ManyToOne
	@JoinColumn(name="cursus_id")
	private Cursus cursus;

	/**
	 * Set of subjects present in this specialty.
	 */
	@OneToMany(mappedBy="specialty", fetch=FetchType.EAGER)
	private Set<SpecialtySubject> specialtySubject;

	/**
	 * Sets the id the the specialty.
	 * @param id
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * Returns the id of the cursus.
	 * @return
	 */
	public long getId() {
		return id;
	}

	/**
	 * Sets the name of the Specialty.
	 * @param name the String that is to be name of the specialty.
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Returns the name of the Specialty.
	 * @return the name of the Specialty.
	 */
	public String getName() {
		return name;
	}

	/**
	 * Sets the description of the Specialty.
	 * @param description the String that is to be the description of the
	 * 		  specialty.
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Returns the description of the Specialty.
	 * @return the description of the specialty.
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Sets the set of cursus of the Specialty.
	 * @param cursus
	 */
	public void setCursus(Cursus cursus) {
		this.cursus = cursus;
	}

	/**
	 * Returns the Cursus associated by the Specialty.
	 * @return the {@link Cursus} associated by the Specialty.
	 */
	public Cursus getCursus() {
		return cursus;
	}

	public void setSpecialtySubject(Set<SpecialtySubject> specialtySubject) {
		this.specialtySubject = specialtySubject;
	}

	public Set<SpecialtySubject> getSpecialtySubject() {
		return specialtySubject;
	}

}
